<?php
	
	
	/**
	 * new self() 和 new static()的区别：
	 * 主要体现在继承上，如果子类继承父类
	 * 1. 前者实例化 
	 */
	class Container {

		public static $instance = null;

		protected $name;

		protected function __construct($name)
		{
			$this->name = $name;
		}

		// 获取实例
		public static function getInstance($name)
		{
			if (!self::$instance) {
				self::$instance = new static($name);
			}

			return self::$instance;
		}

		// get
		public function get()
		{
			echo "i am get";
		}


	}


	Class Application extends Container {

		public function run ()
		{
			echo "i am run";
		}

		public function getCurrentClassName()
		{
			return self::$instance;
		}

		public function getName()
		{
			return $this->name;
		}

	}


	// 使用

	$res = Application::getInstance("beiqiaosu")->getName();

	var_dump($res);

	
?>